/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Fco. Molpeceres Blázquez
 */
public class Server {
    
    ConfigReader lectorConfiguracion;
    ServerSocket socketServidor;
    Socket cliente;
    final int puerto;
    
    public Server(){
        
        lectorConfiguracion = new ConfigReader();
        puerto = Integer.parseInt(ConfigReader.puerto);
        try {
            while(true){
                socketServidor = new ServerSocket(puerto);
                System.out.println("escuchando...");
                cliente = socketServidor.accept();
                ClientThread hiloCliente = new ClientThread(cliente);
                System.out.println("Cliente encontrado!");
                hiloCliente.start();
                socketServidor.close();
            }
        } catch (IOException ex) {
            Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
    public static void main(String [] args){
        
        Server server = new Server();
        
    }
    
}
